package pl.lsierant.j2me.bipacz;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;

import pl.lsierant.j2me.bipacz.player.PlayerManager;
import pl.lsierant.j2me.bipacz.screens.SplashScreen;

public class BipaczMidlet extends MIDlet implements CommandListener {

    public static BipaczMidlet instance;
    private Display display;
    private PlayerManager playerManager;

    public BipaczMidlet() {
        instance = this;
        display = Display.getDisplay(this);
    }

    protected void startApp() {
        startScreen();
        playerManager = new PlayerManager();
    }

    protected void pauseApp() {

    }

    protected void destroyApp(boolean unconditional) {
        playerManager.closePlayers();
        notifyDestroyed();
    }

    public void commandAction(Command cmd, Displayable disp) {

    }

    public void exit() {
        destroyApp(false);
    }

    private void startScreen() {
        display.setCurrent(new SplashScreen(this));
    }

    public static BipaczMidlet getInstance() {
        return instance;
    }

    public PlayerManager getPlayerManager() {
        return playerManager;
    }
}
